import os

from xjlibrary.our_file_dir import BaseDir


class FileUpToLower(object):
    """
    文件大写到小写
    """
    def __init__(self):
        self.sourcepath = ""

    def set_sourcepath(self,sourcepath):
        self.sourcepath = sourcepath

    def uptolower(self):
        for file in BaseDir.get_dir_all_files(self.sourcepath):
            filename = BaseDir.get_file_name(file)
            if any([c.isupper() for c in filename]):
                print(filename)
                print(filename.lower())
                newfilename = file.replace(filename,filename.lower())
                print(newfilename)
                os.rename(file,newfilename)


if __name__ == "__main__":
    ful = FileUpToLower()
    ful.set_sourcepath(r"D:\download\isbn_cover\download\isbncover")
    ful.uptolower()